package practice2;

import java.util.Scanner;

public class P8649{
    public static void main(String[] args) {
        int n, k;
        long ans = 0;
        Scanner sc = new Scanner(System.in);
        n=sc.nextInt();
        k=sc.nextInt();
        int [] sum = new int [100001];
        int [] num = new int [100001];
        int [] cnt = new int [100001];
        for(int i = 1; i <= n; i++){
            num[i] = sc.nextInt();
            sum[i] = (sum[i-1] + num[i])%k;
            ans += cnt[sum[i]];
            cnt[sum[i]]++;
        }
        long a = ans +(long)cnt[0];
        System.out.println(a);
    }

}

